package com.yunduan.management.controller;

import com.yunduan.management.entity.News;
import com.yunduan.management.service.NewsService;
import com.yunduan.management.utils.JsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @author: hy
 * @date: 2020/11/5 21:20
 * @QQ群: 975366488
 */
@RestController
@CrossOrigin
public class NewsController {
    @Autowired
    private NewsService newsService;
    /**
     * 获取所有新闻
     * @return
     */
    @GetMapping("/allNews")
    public JsonObject allNews(){
        return new JsonObject().success(newsService.list());
    }

    @GetMapping("/getNewsById")
    public JsonObject getNew(Long newsId){
        News news = newsService.getById(newsId);
        return new JsonObject().success(news);
    }
}
